//
// Created by lfm on 25-4-7.
//

#include "Student.h"

//静态成员变量类外定义
int Student::total_score = 0;
int Student::count = 0;

void Student::account(int s)
{
    score = s;
    total_score += s;
    count++;
}

int Student::sum()
{
    return total_score;
}

double Student::average()
{
    return (total_score == 0 || count == 0) ? 0 : (double)total_score / count;
}
void Student::input()
{
    while (true)
    {
        cout << "请输入成绩:" << endl;
        int s;
        cin >> s;
        if (s < 0)
        {
            break;
        }

        Student stu;
        stu.account(s);

    }
    cout << "总分: " << Student::sum() << endl;
    cout << "平均分: " << Student::average() << endl;
}